package com.itheima.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealCheckgroupDao {

    @Insert("insert into t_setmeal_checkgroup(setmeal_id, checkgroup_id) values " +
            "(#{setmealId},#{checkgroupId})")
    void insert(Integer setmealId, Integer checkgroupId);

    @Select("select sc.checkgroup_id from t_setmeal s,t_setmeal_checkgroup sc " +
            "where s.id = sc.setmeal_id and s.id = #{setmealId}")
    List<Integer> findCheckGroupIdsBySetmealId(Integer setmealId);

    @Select("select count(*) from t_setmeal_checkgroup " +
            "where setmeal_id = #{id}")
    Integer getBySetmealId(Integer id);

    @Delete("delete from t_setmeal_checkgroup where setmeal_id = #{id}")
    void deleteBySetmealId(Integer id);
}
